<template>
  <div class="app-container">
    <el-form
      class="dialog-form"
      :rules="rules"
      ref="dataForm"
      :model="temp"
      label-position="left"
      label-width="120px"
    >
      <el-form-item label="角色名称" prop="roleName">
        <el-input v-model="temp.roleName" placeholder="角色名称" style="width:300px;"></el-input>
      </el-form-item>
     
      <el-form-item label="描述" prop="description">
        <el-input v-model="temp.description" placeholder="在这里写描述" type="textarea" :rows="3" style="width:300px;"></el-input>
      </el-form-item>

       <!-- <el-form-item label="权限" prop="permissionId">
          <el-select v-model="temp.permissionId" placeholder="请选择权限">
            <el-option v-for="(list,key) in permissionsList" :key="key" :value="list" :label="list"></el-option>
          </el-select>
        </el-form-item> -->

      <!-- <el-form-item label="权限" prop="permissions" v-if="!isEditing">
        <el-tabs v-model="activePermission" @tab-click="handleClick" :value="0">
        <el-tab-pane v-for="perm in permissions" :label="perm.permissionName" :key="perm.id" :name="perm.id+''">
            <el-checkbox v-model="permChecked['checkbox-'+perm.id]" @change="changeChecked(perm,$event)">全选</el-checkbox>
            <el-tree :data="perm.childList" show-checkbox node-key="id" :ref="'tree-'+perm.id" :default-expand-all="true" :props="defaultProps">
            </el-tree>
        </el-tab-pane>
        </el-tabs>
    </el-form-item> -->

    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button size="mini" @click="dialogFormVisible = false">取消</el-button>
      <el-button type="primary" size="mini" :loading="submiting" @click="submitFormAction">确定</el-button>
    </div>
  </div>
</template>

<script>
import "quill/dist/quill.core.css";
import "quill/dist/quill.snow.css";
import "quill/dist/quill.bubble.css";
import { quillEditor, Quill } from "vue-quill-editor";

export default {
  data() {
    return {
      container: false,
      total: 0,
      params: {
        pageNo: 1,
        pageSize: 20
      },
      cmsList: [],
      list: [],
      permissionsList:[],
      temp: {
        permissionId: "34",
        description: ""
      },
      editorOption: {
        placeholder: "在这里输入内容",
        modules: {}
      },
      rules: {
        roleName: [
          {
            required: true,
            message: "角色名称",
            trigger: "change",
            max: 50
          }
        ],
        description: [
          { required: true, message: "描述", trigger: "change" }
        ],
        status: [
          { required: true, message: "排序不能为空", trigger: "change" }
        ],
        permissionId: [{ required: true, message: "状态不能为空", trigger: "change" }]
      }
    };
  },
  components: {
    quillEditor
  },
  created() {
    this.loadData();
     this.$post('/admin/manager/own_permissions/list')
        .then(data => {
          this.permissionsList= data;
          console.log(data)
        })
  },
 
  methods: {
    submitFormAction() {
      this.$refs["dataForm"].validate(valid => {
        if (valid) {
          this.submiting = true;
          const postData = Object.assign({}, this.temp);
          let url = "/admin/manager/role/add";
        //   if (this.isEditing) {
        //     url = "/admin/cms_category/modify";
        //   }
          this.$post(url, postData)
            .then(data => {
                this.$$notify("操作成功");
                this.temp ={};
                this.loadData();
                this.dialogFormVisible = false;
            })
          .finally(err => {
            this.submiting = false
          })
        }
      });
    }
  }
};
</script>
<style>
.el-table td,
.el-table th {
  padding: 1px 0;
}
.el-table {
  font-size: 12px;
}
.opencolor {
  color: red;
}
.openSearch {
  /* width: 100px; */
  margin-bottom: 10px;
  padding-bottom: 5px;
  /* border-bottom: 1px solid #ccc; */
}
</style>